<?php if(!is_array($docs)){$docs = array();}?>
<script>

$(document).ready(function() {
    $("input:text:visible:first").focus();

    <?php foreach($docs as $doc){?>
        $("#show<?php echo $doc->id?>").click(function(){
        	if($('#player<?php echo $doc->id?>').is(':hidden')){
        		   $("#player<?php echo $doc->id?>").slideDown("fast");
        	}else{
        		$("#player<?php echo $doc->id?>").slideUp("fast");
        	}
        });
    <?php }?>
});



</script>

<div id="topspacer" style="position:relative; margin-top:80px;"></div>

&nbsp;&nbsp;
<a href="<?php echo $BASEURL."solr/index/0/json"?>">JSON</a>
|
<a href="<?php echo $BASEURL."solr/index/0/html"?>">HTML</a>
|
<a href="<?php echo $BASEURL."solr/manage_feeds"?>">FEEDS & INDEX MANAGER</a>

<div style="width:720px;">

	<div class="t"><div class="b"><div class="l"><div class="r"><div class="bl"><div class="br"><div class="tl"><div class="tr">
	
    <form method="POST" action="<?php echo $BASEURL?>solr/">
        <table cellpadding="3" cellspacing="0">
        <tr>
            <td>Build Search Query:</td>
            <td><input type="text" name="keywords_search" style="width:450px;" value="<?php echo htmlspecialchars($keywords_search, ENT_QUOTES, 'utf-8');?>" /></td>
            <td colspan="2"><input style="padding:2px; width:100px;" type="submit" value="Search >>" /></td>
        </tr>
        </table>
	</form>
	
	</div></div></div></div></div></div></div></div>
    <div id="results" style="padding:3px; margin-top:20px;">
    
	    <div id="total" style="font-weight:bold;"><?php if($total > 0){echo $total;?> result(s)<?php }?></div>
	    <div id="pages" style="margin-top:10px; font-weight:bold;"><?php if($total > $this->settings->get_param("per_page")){echo "PAGES: " . $search_pages;}?></div>
	    
	    
	    
	    <div id="search_results" style="margin-top:10px;">
	    <?php
	    $resp = array();
        //print_r($docs);
        
	    foreach($docs as $doc){
	    	$resp[]["id"] = $doc->id;
	    	$resp[]["object_type"] = strip_tags($doc->object_type);
	    	$resp[]["title"] = $doc->title;
	    	$resp[]["description"] = strip_tags($doc->description);
	    	$resp[]["url"] = $doc->url;
	    	$resp[]["program"] = $doc->program;
	    	$resp[]["station"] = $doc->station;
	    	$resp[]["score"] = round($doc->score,3);
	    	
	    	if($format == "html"){
	    		?>
	    		<div class="t"><div class="b"><div class="l"><div class="r"><div class="bl"><div class="br"><div class="tl"><div class="tr">
	    		<?php
	    		
	    		$ext_arr = explode(".", $doc->url);
	    		$extension = strtolower(trim($ext_arr[count($ext_arr) - 1]));
	    		
	    		if($doc->title){
	    			$title = $doc->title;
	    		}elseif($doc->url){
	    			$title = $doc->url;
	    		}else{
	    			$title = "<b>NO TITLE</b>";
	    		}
	    		if($doc->object_type != 'flickr'){
	    			$descr = $doc->description;
	    		}else{
	    			$descr = $doc->description;
	    		}
	    		
	    		
	    		?>
	    		
	    		<table cellpadding="4" cellspacing="0">
                <tr>
                    <td valign="top">
                	    		
	    		<?php 
	    	    echo "<b>[" . $doc->object_type . "]</b><br />";
		    	echo "<a style='font-weight:bold;' href='".$doc->url."' target='_blank'>" . $title . "</a><br />";
		    	if($doc->description){echo  $descr . "<br />";}
		    	
	    	    
	    	    
		        if($doc->date){echo "<b>" . $doc->date . "</b><br />";}
		        if($doc->program){echo "<b>PROGRAM: " . $doc->program . "</b><br />";}
		        if($doc->station){echo "<b>STATION: " . $doc->station . "</b><br />";}
		        echo "<span style='font-weight:bold; font-size:10px; font-family:helvetica,tahoma;'>SCORE: " . round($doc->score,3)."</span><br />";
	    	    if($doc->topic){echo "<span style='font-size:10px;'>TOPIC: <i>" . $doc->topic . "</i></span><br />";}
		        echo "<span style='font-size:11px; font-family:helvetica,tahoma; color:green;'>".$doc->url."</span><br />";
		        
		        
		        ?>
		        
		          </td>
		          
		          <?php if($extension == "mp3" || $extension == "mp4" || $extension == "flv" || $extension == "m4v"){?>
		          <td valign="top" style="width:320px;">
		            <div id="show<?php echo $doc->id?>" style="cursor:pointer; font-size:10px; font-weight:bold; color:blue; text-decoration:underline;">Preview</div>
		            <?php if($extension == "mp3"){$height = "25";}else{$height = "250";}?>
		            <div id="player<?php echo $doc->id?>" style="display:none; width:320px; height:<?php echo $height;?>px;"></div>
		            <script>
			        $f("player<?php echo $doc->id?>", "<?php echo $BASEURL?>swf/flowplayer-3.1.5.swf", { 
			            plugins: { 
			                audio: { 
			                    url: '<?php echo $BASEURL?>swf/flowplayer.audio-3.1.2.swf' 
			                }
			            },
			            
			           playlist: [ 
			                   
			                   // setup album cover scaling 
			                   {url: '<?php echo $BASEURL?>images/mp3.png', scaling: 'orig'}, 
			                
			                   // our media file does not start automatically 
			                   {url: '<?php echo $doc->url?>', autoPlay: false} 
			                
			               ]
			            
			        });
			        </script>
		          
		          
		          </td>
		          <?php }?>
		          
		       </tr>
		       </table>
		        
		    	</div></div></div></div></div></div></div></div><br />
		    	<?php
	    	}
	    	
	    }
	    if($format == "json"){
	       echo "<pre>".nl2br(json_encode($resp))."</pre>";
	    }
	    ?>
	    </div>
        <div id="pages_down" style="margin-top:10px; font-weight:bold;"><?php if($total > $this->settings->get_param("per_page")){echo "PAGES: " . $search_pages;}?></div>
        
    </div>

</div>
